package com.deco.logic.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import com.deco.dao.delegate.brand.IBrandStoryDao;
import com.deco.dao.delegate.sys.ICmsAdvDao;
import com.deco.domain.vo.brand.BrandStoryVo;
import com.deco.domain.vo.sys.CmsAdvTypeVo;
import com.deco.domain.vo.sys.CmsAdvVo;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Component
public class CmsAdvLogic {
    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/
    
    @Autowired
    ICmsAdvDao cmsAdvDao;

    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/
	@Cacheable(value = "cmsAdv",key = "#advVo")
	public List<CmsAdvVo> list(CmsAdvVo advVo,String orderBy){
		return cmsAdvDao.selectList(advVo,orderBy);
	}

	public CmsAdvVo getCmsAdv(int id) {
		CmsAdvVo cmsAdvVo = new CmsAdvVo();
		cmsAdvVo.setId(id);
		return cmsAdvDao.selectOne(cmsAdvVo);
	}

	@CacheEvict(value = "cmsAdv",allEntries = true)
	public void create(CmsAdvVo cmsAdvVo) {
		cmsAdvDao.add(cmsAdvVo);
		
	}

	@CacheEvict(value = "cmsAdv",allEntries = true)
	public void update(CmsAdvVo cmsAdvVo) {
		cmsAdvDao.update(cmsAdvVo);
		
	}

	@CacheEvict(value = "cmsAdv",allEntries = true)
	public void delete(int id) {
		cmsAdvDao.delete(id);
	}

	@CacheEvict(value = "cmsAdv",allEntries = true)
	public int batchDelete(Integer[] ids) {
		return cmsAdvDao.batchDelete(ids);
	}

	public PageResponseVo<CmsAdvVo> getPageInfo(PageSearchVo<CmsAdvVo> condition) {
		return cmsAdvDao.selectByPageNoTitleLike(condition.getConditionVo(), " id desc ", condition.getCurrentNo(), condition.getLength());
	}

	@Cacheable(value = "cmsAdv")
	public List<CmsAdvVo> getAll() {
		CmsAdvVo cond = new CmsAdvVo();
		return cmsAdvDao.selectList(cond , "");
	}

    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
